import java.util.Arrays;
import java.util.Scanner;


public class E2 {


	/**
	 * @param args
	 */
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);	
	
		System.out.println("Enter n:");
		int n=scanner.nextInt();
		System.out.println("Enter k:");
		int k=scanner.nextInt();
	
		int[] intArray=new int[n];
	
		for (int i=0;i<n;i++){
			System.out.println("next:");
			intArray[i]=scanner.nextInt();
		}
		
		Arrays.sort(intArray);
		int intArrayIndex=Arrays.binarySearch(intArray, k);
		if (intArrayIndex>=0)
			System.out.println(intArray[intArrayIndex]);
		else { 
			//System.out.println(intArrayIndex);
			System.out.println(intArray[(intArrayIndex)*(-1)-2]);
		}
		
	}	
}
